<template>
	<view>
		<button @click="getGoods">转入商品分类</button>
		<button @click="postRecommends">转入推荐</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
      recommendList: [{
          id: '10524',
          topTitle: '法式经典',
          enTitle: 'French Classics',
          topImg: 'https://mcake-oss.oss-cn-hangzhou.aliyuncs.com/file/002d8ec99b74dccd/15c31d4729a3eecc.jpg',
          list: [{
              id: '001',
              img: 'https://static.mcake.com/new_goods/lanmeiqingrunapolun/N0301/list/1.jpg',
              name: '蓝莓轻乳拿破仑大总统',
              label: '今日现代',
              french: 'La Forêt noir ji ni tai mei',
              price: '198.00',
              lowerShelf: false
            },
            {
              id: '002',
              img: 'https://static.mcake.com/new_goods/lanmeiqingrunapolun/N0301/list/1.jpg',
              name: '蓝莓轻乳拿破仑大总统',
              label: '今日现代',
              french: 'La Forêt noir ji ni tai mei',
              price: '198.00',
              lowerShelf: false
            },
            {
              id: '003',
              img: 'https://static.mcake.com/new_goods/lanmeiqingrunapolun/N0301/list/1.jpg',
              name: '蓝莓轻乳拿破仑大总统',
              label: '今日现代',
              french: 'La Forêt noir ji ni tai mei',
              price: '198.00',
              lowerShelf: false
            },
          ]
        },
        {
          id: '15438',
          topTitle: '节日系列',
          enTitle: 'French Classics',
          topImg: 'https://mcake-oss.oss-cn-hangzhou.aliyuncs.com/file/002d8ec99b74dccd/15c31d4729a3eecc.jpg',
          list: [{
            id: '001',
            img: 'https://static.mcake.com/new_goods/lanmeiqingrunapolun/N0301/list/1.jpg',
            name: '蓝莓轻乳拿破仑',
            label: '明星款',
            price: '198.00',
            lowerShelf: true
          }]
        },
        {
          id: '1212',
          topTitle: '儿童系列',
          enTitle: 'French Classics',
          topImg: 'https://mcake-oss.oss-cn-hangzhou.aliyuncs.com/file/002d8ec99b74dccd/15c31d4729a3eecc.jpg',
          list: []
        }
      ],
			}
		},
		methods: {
			getGoods() {
				uni.request({
					url: "https://h5.mcake.com/api/0434b49d1ac28f9d?cityId=110&page=1&bid=5",
					header: {
						"access-token": "3e5c98fa27d19852427cf1b45f0103d4",
						"version": "v1.0"
					},
					success: (res) => {
						console.log(res);
						let batchObj = {
							"requests": []
						}
						res.data.data.list.forEach((item, index) => {
							batchObj.requests.push({
								"method": "POST",
								"path": "/1.1/classes/classify",
								"body": item
							})
						})
						this.$H.post('/1.1/batch', batchObj)
					}
				})
			},
      postRecommends(){
						let batchObj = {
							"requests": []
						}
						this.recommendList.forEach((item, index) => {
							batchObj.requests.push({
								"method": "POST",
								"path": "/1.1/classes/recommends",
								"body": item
							})
						})
						this.$H.post('/1.1/batch', batchObj).then(res => {
              console.log(res);
            })
					}
		}
	}
</script>

<style>
	button {
		width: 80%;
		margin-bottom: 20rpx;
	}
</style>
